package com.thti.mecool.client.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.thti.mecool.client.activity.R;
import com.thti.mecool.client.model.po.Communication;

public class CommunicationShowAdapter extends BaseAdapter {
	private Context mContext;
	List<Communication> communications2;
	@Override
	public boolean isEnabled(int position) {
		// TODO Auto-generated method stub
		return false;
	}

	public CommunicationShowAdapter(Context mContext,
			List<Communication> communications2) {
		super();
		this.mContext = mContext;
		this.communications2 = communications2;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return communications2.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return communications2.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder=null;
		if(convertView==null){
			LayoutInflater inflater=LayoutInflater.from(mContext);
			convertView=inflater.inflate(R.layout.mecool_communiction_first, null);
			holder=new ViewHolder();
			holder.title=(TextView)convertView.findViewById(R.id.mecool_communiction_title);
			holder.time=(TextView)convertView.findViewById(R.id.mecool_communiction_time);
			holder.project=(TextView)convertView.findViewById(R.id.mecool_communiction_project);
			holder.shop=(TextView)convertView.findViewById(R.id.mecool_communiction_shop);
			holder.form=(TextView)convertView.findViewById(R.id.mecool_communiction_form);
			holder.name=(TextView)convertView.findViewById(R.id.mecool_communiction_name);
			holder.occupation=(TextView)convertView.findViewById(R.id.mecool_communiction_position);
			holder.tel=(TextView)convertView.findViewById(R.id.mecool_communiction_tel);
			holder.content=(TextView)convertView.findViewById(R.id.mecool_communiction_content);
			convertView.setTag(holder);
		}else{
			holder=(ViewHolder)convertView.getTag();
		}
		
		holder.title.setText(communications2.get(position).getTitle());
		holder.time.setText(communications2.get(position).getRecordDate());
		holder.project.setText(communications2.get(position).getProjName());
		holder.shop.setText(communications2.get(position).getProjStoreName());
		holder.form.setText(communications2.get(position).getType());
		holder.name.setText(communications2.get(position).getContactName());
		holder.occupation.setText(communications2.get(position).getContactPosition());
		holder.tel.setText(communications2.get(position).getContactPhoneOrOther());
		holder.content.setText(communications2.get(position).getContent());
		return convertView;
	}

	class ViewHolder{
		public TextView title,time,project,shop,form,name,occupation,tel,content;
	}
	
}
